package com.smap.marker;

import com.google.gwt.dom.client.Style.Overflow;
import com.google.gwt.user.client.ui.Image;
import com.smap.RS;
import com.smap.common.Utils;
import com.smap.core.Marker;
import com.smap.core.XY;

public class Popup extends Marker {
	Image background = null;

	public void init() {
		super.init();
		this.setWidth("224px");
		this.setHeight("180px");
		this.html.getElement().getStyle().setBackgroundColor("white");
		this.html.getElement().getStyle().setOverflowY(Overflow.AUTO);
		this.html.getElement().getStyle().setOverflowX(Overflow.HIDDEN);
		background = new Image(RS.INSTANCE.popup());
		addToBack(background);
		this.setCenter(110, 230);
	}

	static Popup inst;

	public static Popup get() {
		if (inst == null) {
			inst = new Popup();
		}
		return inst;
	}

	@Override
	public XY setPosition(XY xy) {
		XY pos = super.setPosition(xy);
		Utils.setPosition(background, (int) pos.x - 10, (int) pos.y - 10);
		return pos;
	}
}
